//package example;
//
//import java.util.ArrayList;
//import java.util.List;
//
//public class VideoSystem {
//    public static final int NORMAL_SPEED = 1;
//    public static final int SLOW_SPEED = 0;
//    public static int SEG_TIME = 3;
//    int segTime = 3;
//    int time = 0;
//    int currentSeg = 0;
//    int currentSegRate = 0;
//    int currentSegSpeed = 0;
//
//    int segStartTime = 0;
//    int segEndTime = 0;
//    int nextSegRate = 0;
//    int nextSegSpeed = 0;
//    int totalUsage = 0;
//    int[] ratesArray;
//    int segTimeIndex = 0;
//    int nextSegPlayTime = 0;
//    SegPlayInfo currentSegPlayInfo;
//    SegPlayInfo nextSegPlayInfo;
//    List<SegPlayInfo>  segPlayInfoList = new ArrayList<SegPlayInfo>();
//
//    VideoSystem(int[] rates, int segtime, int rateIdx) {
//        ratesArray = rates;
//        currentSegRate = rates[rateIdx];
//        currentSegRate = NORMAL_SPEED;
//        SEG_TIME = segtime;
//        SegPlayInfo segPlayInfo = new SegPlayInfo(currentSeg,currentSegRate,currentSegSpeed,time);
//        segPlayInfoList.add(segPlayInfo);
//        currentSegPlayInfo = segPlayInfo;
//    }
//
//    int switchRate(int time, int rateIdx) {
//        if (time == currentSegPlayInfo.getEndTime()) {
//            currentSegRate = ratesArray[rateIdx];
//        }
//        if (time < currentSegPlayInfo.getEndTime()) {
//            nextSegRate = ratesArray[rateIdx];
//        }
//        return ratesArray[rateIdx];
//    }
//
//    void switchSpeed(int time) {
//        if (time == currentSegPlayInfo.getEndTime()) {
//            if (currentSegSpeed == NORMAL_SPEED) {
//                currentSegSpeed = SLOW_SPEED;
//            } else {
//                currentSegSpeed = NORMAL_SPEED;
//            }
//        }else {
//            if (nextSegSpeed == NORMAL_SPEED) {
//                nextSegSpeed = SLOW_SPEED;
//            } else {
//                nextSegSpeed = NORMAL_SPEED;
//            }
//        }
//
//    }
//
//    public int getEndTime() {
//        if (currentSegSpeed == VideoSystem.NORMAL_SPEED){
//            segEndTime = segStartTime + VideoSystem.SEG_TIME;
//        }else {
//            segEndTime = segStartTime + VideoSystem.SEG_TIME*2;
//        }
//        return segEndTime;
//    }
//
//    Result stop(int time) {
//        int totalUsage = 0;
//        for (SegPlayInfo segPlayInfo : segPlayInfoList) {
//            totalUsage = segPlayInfo.getPlayRate() * 3;
//        }
//        return new Result(segPlayInfoList.size(), totalUsage);
//    }
//}
